Taking data from unsaved Excel file

Hello,

is there any way to take data from unsaved Excel file?

Use case:

- export data into Excel file,

- some modifications on it in Excel file,

- without to save the Excel file import into DOORS.

(Currently everything works, but only in case I save the Excel file.)

P.S.: I would like to stay in the same Excel file. Saving of the file isn't allowed.


Anta_st - Wed Sep 02 11:45:27 EDT 2015

Re: Taking data from unsaved Excel file
Wolfgang Uhr - Wed Sep 02 11:50:21 EDT 2015

I do not understand the problem. Of course you can write some data to excel and then I can read it again without saving the file.

Re: Taking data from unsaved Excel file
Anta_st - Thu Sep 03 03:08:32 EDT 2015

Good morning Wolfgang,

based on your reply I tested further, but the result is still the same:

- in case of new unsaved data in Excel file, dxl doesn't recognize them and doesn't update the module if I run the import code,

- in case I save the data in Excel file, dxl recognize them and update module accordingly if I run the import code.

(So the only modification is before to run Import DXL I save the current Excel file, in macro:

        Call SaveFile
        Call StartImportDXL

does work,

just only

        Call StartImportDXL

doesn't work.)

I do following steps:

- export selected data in module into Excel file,

- collect external data and the exported data in the other sheet,

- import the new data from the other sheet.

Do you have any ideas?

Re: Taking data from unsaved Excel file
Wolfgang Uhr - Thu Sep 03 04:30:47 EDT 2015

Anta_st - Thu Sep 03 03:08:32 EDT 2015

Good morning Wolfgang,

based on your reply I tested further, but the result is still the same:

- in case of new unsaved data in Excel file, dxl doesn't recognize them and doesn't update the module if I run the import code,

- in case I save the data in Excel file, dxl recognize them and update module accordingly if I run the import code.

(So the only modification is before to run Import DXL I save the current Excel file, in macro:

        Call SaveFile
        Call StartImportDXL

does work,

just only

        Call StartImportDXL

doesn't work.)

I do following steps:

- export selected data in module into Excel file,

- collect external data and the exported data in the other sheet,

- import the new data from the other sheet.

Do you have any ideas?

Hi

I do not know what your script is doing. But if I wirte something to an excel cell

olePut(objRange, "Value", "A very importante remark");

I can read back this data imedately

string sSomeValue;

oleGet(objRange, "Value", sSomeValue);

print sSomeValue "\n";

Best regards

Wolfgang

Re: Taking data from unsaved Excel file
Anta_st - Tue Sep 08 10:35:52 EDT 2015

Wolfgang Uhr - Thu Sep 03 04:30:47 EDT 2015

Hi

I do not know what your script is doing. But if I wirte something to an excel cell

olePut(objRange, "Value", "A very importante remark");

I can read back this data imedately

string sSomeValue;

oleGet(objRange, "Value", sSomeValue);

print sSomeValue "\n";

Best regards

Wolfgang

Hello Wolfgang,

I've identified the place in code

(code was taken from "Import from Excel" DXL

 * Copyright (c) 2007-2008
 * AAI Services Inc.
 * A Textron Systems Subsidiary
 *
 * Author: David Pechacek

and modified by me)

------------------------------------------------------------------------------------------------

/*
 * Gets a handle on a specific cell based on a cell location such as A9.
 * Remember, the minimum row and column number in Excel is 1, not 0.  The
 * maximum column number is 256.  Office 97 and 2000 have a limit of 65536
 * rows.  Office XP and 2003 can go beyond this.  However for DOORS this
 * should not be an issue.
 */
bool getCell(string loc) {
   closeIfNonNull(objCell);      // close any open handle to a cell
   clear(args);                   // clear any current arguments
   put(args, loc "");             // loc is in the format of A9 or B37
  
   checkResult(oleGet(objSheet, cMethodRange, args, objCell));      // get a handle to the cell
  
   if(null(objCell)) {
      errorBox("Unable to get cell object");
      return(false);
   }
  
   checkResult(oleMethod(objCell, cMethodSelect));
  
   return(true);
}

 

string getCellText(int rowNum, int col) {
   string s = "";
   getCell(rowNum, col);   // gets a handle on the desired cell.
  
   // if the handle of a cell was returned, get the value
   if(!null(objCell)) {
      if(!checkResult(oleGet(objCell, cPropertyText, s))) {
         errorBox("Failed to get cell " intToCol(col) "" rowNum " value");
         return("error");
      }
   }
   else {   // otherwise returns error as the result
      return("error");
   }
  
   return(s);


}/*
 * Gets the number of rows and columns from the Excel sheet.  Counts by the first
 * row and column until it finds a blank.
 */
bool getFileRowsAndCols() {
   int i = 0
   Buffer temp = create
   // get the number of rows
   while(true) {
      temp = trimWhitespace(getCellText(++i, 1))
print i 
      if(tempStringOf(temp) == errorStr) {
         delete(temp)
         return false
      }
      else if(tempStringOf(temp) == "") {
         break
      }
   }
  
   totalRows = i-1
   i = 0
   // get the number of columns
   while(true) {
      temp = trimWhitespace(getCellText(1, ++i))    
      if(tempStringOf(temp) == errorStr) {
         delete(temp)
         return false
      }
      else if(tempStringOf(temp) == "") {
         break
      }
   }
  
   delete(temp)
   totalColumns = i-1
   return true
}

 

I have in Excel in column A1 "Object Identifier" (saved in Excel).

In column A2 I have "xx_1" (not saved in Excel).

The entries weren't done by DXL.

 

If I run the code above DXL returns only the entry in column A1.

Do you know what is wrong here?

Re: Taking data from unsaved Excel file
Wolfgang Uhr - Mon Sep 14 07:34:47 EDT 2015

Anta_st - Tue Sep 08 10:35:52 EDT 2015

Hello Wolfgang,

I've identified the place in code

(code was taken from "Import from Excel" DXL

 * Copyright (c) 2007-2008
 * AAI Services Inc.
 * A Textron Systems Subsidiary
 *
 * Author: David Pechacek

and modified by me)

------------------------------------------------------------------------------------------------

/*
 * Gets a handle on a specific cell based on a cell location such as A9.
 * Remember, the minimum row and column number in Excel is 1, not 0.  The
 * maximum column number is 256.  Office 97 and 2000 have a limit of 65536
 * rows.  Office XP and 2003 can go beyond this.  However for DOORS this
 * should not be an issue.
 */
bool getCell(string loc) {
   closeIfNonNull(objCell);      // close any open handle to a cell
   clear(args);                   // clear any current arguments
   put(args, loc "");             // loc is in the format of A9 or B37
  
   checkResult(oleGet(objSheet, cMethodRange, args, objCell));      // get a handle to the cell
  
   if(null(objCell)) {
      errorBox("Unable to get cell object");
      return(false);
   }
  
   checkResult(oleMethod(objCell, cMethodSelect));
  
   return(true);
}

 

string getCellText(int rowNum, int col) {
   string s = "";
   getCell(rowNum, col);   // gets a handle on the desired cell.
  
   // if the handle of a cell was returned, get the value
   if(!null(objCell)) {
      if(!checkResult(oleGet(objCell, cPropertyText, s))) {
         errorBox("Failed to get cell " intToCol(col) "" rowNum " value");
         return("error");
      }
   }
   else {   // otherwise returns error as the result
      return("error");
   }
  
   return(s);


}/*
 * Gets the number of rows and columns from the Excel sheet.  Counts by the first
 * row and column until it finds a blank.
 */
bool getFileRowsAndCols() {
   int i = 0
   Buffer temp = create
   // get the number of rows
   while(true) {
      temp = trimWhitespace(getCellText(++i, 1))
print i 
      if(tempStringOf(temp) == errorStr) {
         delete(temp)
         return false
      }
      else if(tempStringOf(temp) == "") {
         break
      }
   }
  
   totalRows = i-1
   i = 0
   // get the number of columns
   while(true) {
      temp = trimWhitespace(getCellText(1, ++i))    
      if(tempStringOf(temp) == errorStr) {
         delete(temp)
         return false
      }
      else if(tempStringOf(temp) == "") {
         break
      }
   }
  
   delete(temp)
   totalColumns = i-1
   return true
}

 

I have in Excel in column A1 "Object Identifier" (saved in Excel).

In column A2 I have "xx_1" (not saved in Excel).

The entries weren't done by DXL.

 

If I run the code above DXL returns only the entry in column A1.

Do you know what is wrong here?

Hi

No in this way I do not see any way to help you.

Some points:

1. You must not use the selct methods!

You (or the IBM-Script) uses the selection obect of excel.

checkResult(oleMethod(objCell, cMethodSelect));

And this "cMethodSelect"-Selection is the wrong method. Any Mouseclick or some arbitrary event on your PC may create an error in your script.

2. Your comment is not the thing you have written

getCell(rowNum, col); // gets a handle on the desired cell.

The function has the name "get" and the comment speaks about a handle. But the routine did not have any output parameter. That means that you are dealig whith global constants. So I only can guess what the program is doing and I only can guess, what is going wrong.

Sorry ...

Best regards

Wolfgang

 

 

Re: Taking data from unsaved Excel file
Anta_st - Mon Sep 14 08:33:33 EDT 2015

Wolfgang Uhr - Mon Sep 14 07:34:47 EDT 2015

Hi

No in this way I do not see any way to help you.

Some points:

1. You must not use the selct methods!

You (or the IBM-Script) uses the selection obect of excel.

checkResult(oleMethod(objCell, cMethodSelect));

And this "cMethodSelect"-Selection is the wrong method. Any Mouseclick or some arbitrary event on your PC may create an error in your script.

2. Your comment is not the thing you have written

getCell(rowNum, col); // gets a handle on the desired cell.

The function has the name "get" and the comment speaks about a handle. But the routine did not have any output parameter. That means that you are dealig whith global constants. So I only can guess what the program is doing and I only can guess, what is going wrong.

Sorry ...

Best regards

Wolfgang

 

 

Hello Wolfgang,

thanks a lot for your time and comments!!

I will have a look how I could do it in the most appropriate / right way :).

Best regards,

Re: Taking data from unsaved Excel file
Wolfgang Uhr - Mon Sep 14 11:48:34 EDT 2015

Anta_st - Mon Sep 14 08:33:33 EDT 2015

Hello Wolfgang,

thanks a lot for your time and comments!!

I will have a look how I could do it in the most appropriate / right way :).

Best regards,

You do not understand the problem, do you?

Without any specific question, I only can post a text in this forum, which I easily can sell in form of a book.

Please post questions which can be answered in less than 1.000 Words.

Re: Taking data from unsaved Excel file
Anta_st - Mon Sep 14 15:19:15 EDT 2015

Wolfgang Uhr - Mon Sep 14 11:48:34 EDT 2015

You do not understand the problem, do you?

Without any specific question, I only can post a text in this forum, which I easily can sell in form of a book.

Please post questions which can be answered in less than 1.000 Words.

Did you write to me or was it a mistake?